home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DS-CD ROM 2 1993 August
/
DS CD-ROM 2.Ausgabe (August 1993).iso
/
programm
/
ds0256
/
mdebug1.exe
/
KONVERT.A86
< prev
next >
Wrap
Text File
|
1992-11-20
|
3KB
|
137 lines
; ----------------------------
; KONVERT
;
; Enthält: Assembler-Routinen zur Konvertierung von Werten in Hexstrings
;
; Autor: Bernd Schemmer
; Jahnstr. 58
; 6000 Frankfurt 1
; Tel.: (069) 59 54 57
;
; System: IBM-PC/AT/Kompatibler
; Hardware: -
; Betriebs-System: DOS 3.xx
; Sprache: Assembler
; Compiler: A86
;
; Letzter Update: 12.07.1992
;
; Besonderheiten: Alle Routinen sind als FAR-Routinen kodiert
;
; Übersetzen: A86 KONVERT.A86 to KONVERT.OBJ
;
; ----------------------------
CODE SEGMENT BYTE PUBLIC
ASSUME CS:CODE
; ----------------------------
PUBLIC HexByte
PUBLIC HexWord
; ----------------------------
; HexByte
;
; Funktion: Umwandeln eines Bytes in einen HexString
;
; Pascal-Deklaration: {$F+} FUNCTION HexByte(zahlb : BYTE):STRING; EXTERNAL; {$F-}
;
; Eingabe-Parameter: zahlb - Umzuwandelndes Byte
;
; Ausgabe-Parameter: Als Funktions-Wert wird der HexString zurueckgegeben
;
; Besonderheiten: Der Funktions-Wert ist immer 2 Zeichen lang
;
zahlb EQU [BP+06h] ; Offsets der Parameter auf dem Stack
str2 EQU [BP+08h]
HexByte PROC FAR
push bp
mov bp,sp
cld
les di,str2
mov b es:[di],02h
inc di
mov al,zahlb
call Konvert_AL_TO_AX
stosw
pop bp
retf 2
; ----------------------------
; HexWord
;
; Funktion: Umwandeln eines Wortes in einen HexString
;
; Pascal-Deklaration: {F+} FUNCTION HexWord(zahlw : WORD):STRING; EXTERNAL; {$F-}
;
; Eingabe-Paramter: zahlw - umzuwandelndes Wort
;
; Augabe-Paramter: Als Funktions-Wert wird der HexString zurueckgegeben
;
; Besonderheiten: Der Funktions-Wert ist immer 4 Zeichen lang
;
zahlw EQU [BP+06] ; Offsets der Parameter auf dem Stack
str4 EQU [BP+08]
HexWord PROC FAR
push bp
mov bp,sp
cld
les di,str4
mov b es:[di],4
inc di
mov ax,zahlw
push ax
mov al,ah
call Konvert_AL_TO_AX
stosw
pop ax
call Konvert_AL_TO_AX
stosw
pop bp
retf 2
; ---------------------------
; Konvert_AL_To_AX
;
; Funktion: Konvertiert AL in einen Hexstring
;
; Eingabe: AL = zu konvertierender Wert
;
; Ausgabe: AL = oberes Nibble als Hexziffer
; AH = unteres Nibble als Hexziffer
;
Konvert_AL_TO_AX PROC NEAR
mov ah,al
and ah,0F0h
shr ah,1
shr ah,1
shr ah,1
shr ah,1
cmp ah,9xD
jg >l1
add ah,'0'
jmp >l2
l1:
add ah,'7'
l2:
and al,0Fh
cmp al,9xD
jg >l1
add al,'0'
jmp >l2
l1:
add al,'7'
l2:
xchg ah,al
ret
CODE ENDS
; ----------------------------